<type_traits>

public member function
<type_traits>

std::integral_constant::operator value_type

constexpr operator value_type();
Returns value
Returns the value of the integral_constant.

For true_type, this is true.
For false_type, this is false.
For any other instantitiation of integral_constant this is the same as its second template parameter.

Parameters

none

Return value

The value of the integral_constant.
value_type is an alias of the first class template parameter (T).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// integral_constant::operator value_type example
#include <iostream>
#include <type_traits>

int main() {
  // is_integral<T> inherits from integral_constant

  if ( std::is_integral<int>() )
    std::cout << "int is an integral type" << std::endl;

  // same result as:
  if ( std::is_integral<int>::value )
    std::cout << "int is an integral type" << std::endl;

  return 0;
}

Output:
int is an integral type
int is an integral type


See also